<template lang="html">
  <div class="">
      <div class="tab1">
          <div class="title">套餐新增</div>
          <div class="form">
              <div class="form_item" v-for="(item,index) in aGoods" :key="index">
                  <span> <i>*</i> 商品{{index+1}}</span>
                  <el-button type="primary" size="mini" @click="handleSelectGood(index)" >请选择</el-button>
                  <el-button type="text" class="add_good" @click="handlePush" v-if="(aGoods.length-1) == index">添加商品</el-button>
                  <el-button type="text" class="del_good" @click="handleDel(index)" v-if="aGoods.length != 1">删除商品</el-button>
              </div>
              <div class="form_item">
                  <span> <i>*</i> 优惠比例</span>
                  <el-input v-model="proportion"></el-input>
                  <span>%</span>
              </div>
          </div>
          <div class="submit_form">
              <el-button type="primary" size="medium" @click="submit">提交</el-button>
          </div>
      </div>
      <el-dialog :visible.sync="dialogVisible" width="30%">

          <div class="form">
              <el-form :inline="true">
                  <el-form-item >
                    <el-input v-model="dialogForm.user" placeholder="请输入商品名称或编号"></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="onSearch">搜索</el-button>
                  </el-form-item>
                  <el-form-item label="类型">
                    <el-select v-model="dialogForm.region">
                      <el-option label="区域一" value="shanghai"></el-option>
                      <el-option label="区域二" value="beijing"></el-option>
                    </el-select>
                  </el-form-item>
              </el-form>
          </div>

          <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="confirm">确 定</el-button>
          </span>
      </el-dialog>

  </div>
</template>

<script>
export default {
  data(){
    return {
      proportion:'',
      aGoods: [''],
      dialogVisible:false,
      dialogForm:{}
    }
  },
  created(){

  },
  methods: {

    submit(){
      console.log(this.aGoods)
    },
    handlePush(){
      this.aGoods.push('')
    },
    handleDel(index){
      this.aGoods.splice(index,1)
    },
    handleSelectGood(){
      this.dialogVisible = true;
    },
    onSearch(){},
    confirm(){

    },


  }
}
</script>

<style lang="css" scoped>
i{font-style: normal}
.tab1{
  background: #fff;
  margin-bottom: 10px;
  box-sizing: border-box;
  border: 1px solid #E8E8E8;
}
.form{
  width: 38%;
  padding: 20px 0;
  margin-left: 50px;
}
.form .form_item{
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}
.form .form_item>span:nth-of-type(1){
  font-size: 13px;
  color: #333333;
  margin-right: 10px;
  width: 80px;
  display: inline-block;
}
.form .form_tag{
  margin-right: 10px;
}
.tab1 i{
  color: #FB3F3F;
}
.form_item .el-input{
  width: 200px
}
.form_item .add_good{
  margin-left: 30px
}
.form_item .del_good{
  margin-left: 30px;
  color: #FB3F3F
}
.title{
  width: 100%;
  color: #4196FF;
  padding: 12px 15px;
  background-color:#DAEBFF;
  box-sizing: border-box;
}
.form2 .form_title{
  font-size: 13px;
  color: #333333;
  margin-right: 10px;
  line-height: 60px;
  height: 40px;
  margin-left: 50px
}
.submit_form{
  margin-left: 50px;
  padding-bottom: 50px;
}
</style>
